#!/usr/bin/env python2.7
# -*- coding:utf-8 -*- 

import os, sys, re
from metlib.kits import *
# from project.models import *

varname_dict = {
    # WRF
    "wspd": u"风速",
    "wdir": u"风向",
    "wspd10m": u"10米风速",
    "wdir10m": u"10米风向",
    "ust": u"摩擦速度",
    "wpd": u"风功率密度",
    "td": u"温度",
    "t": u"温度",
    "t2m": u"2米温度",
    "psfc": u"气压",
    "p": u"气压",
    "rhoair": u"空气密度",
    "rh": u"相对湿度",
    "rh2m": u"2米相对湿度",
    "q2m": u"2米比湿",
    "tdew2m": u"2米露点温度",
    "summary": u"汇总统计",
    "sfc_summary": u"地面汇总",
    "windrose": u"风玫瑰",
    "wpdrose": u"风功率玫瑰",
    "dist": u"风速分布",
    "eqhour": u"等效小时数",
    "rain": u"降雨",
    "snow": u"降雪",
    "ts": u"地表温度",
    "tskin": u"地表温度",
    "slp": u"海平面气压",
    "swdown": u"向下短波辐射",
    "glw": u"向下长波辐射",
    "ghi": u"向下短波辐射",
    "dni": u"法向直接短波辐射",
    "ddir": u"直接短波辐射",
    "ddif": u"散射短波辐射",

    # Merra
    "ws50m": u"风速(50m)",
    "wd50m": u"风向(50m)",
    # "wpd": u"风功率密度",
    "t10m": u"温度(10m)",
    # "t2m": u"温度(2m)",
    # "ts": u"温度(地面)",
    # "slp": u"海平面气压",
    "ps": u"地面气压",
    "disph": u"位移高度",
    "mean": u"汇总统计",
    "rose": u"风玫瑰",
    # "windrose": u"风玫瑰",
    # "wpdrose": u"风功率玫瑰",
    # "dist": u"风速分布",

    # CCMP
    "ws10m": u"风速(10m)",
    "wd10m": u"风向(10m)",
    # "mean": u"汇总统计",
    # "rose": u"风玫瑰",
    # "windrose": u"风玫瑰",
    # "dist": u"风速分布",

    # Solar
    'daily_total_rad': u'日总辐射量',
    'total_rad': u'年总辐射量',
    'year_total_rad': u'年总辐射量',
    'month_total_rad': u'月总辐射量',
    # 'summary': u'汇总统计'
}

def run():
    try:
        pass
        # for ss in WrasSnapshot.objects.all():
        #     print "Fixing varname for %s" % ss
        #     html = ss.html
        #     m = re.match(r'(?P<pre>.*<div class="ttblock varname icon_)(?P<varname>[^">]+)(?P<post1>">)(?P<post2></div>.*)', html)
        #     if m:
        #         varname = m.group('varname')
        #         zh_varname = varname_dict.get(varname, varname)
        #         new_html = u'{}{}{}<span>{}</span>{}'.format(
        #             m.group('pre'), varname, m.group('post1'), zh_varname, m.group('post2')
        #         )
        #         print u"    {} -> {}".format(varname, zh_varname)
        #         print new_html
        #         ss.html = new_html
        #         ss.save(update_fields=['html'])
    except Exception as e:
        print e

